vi
, one of the standard text editors on UNIX
systems. VIM adds many of the features that you would expect in
an editor: unlimited undo, syntax coloring, split windows, visual
selection, graphical user interface, and much much more."
CTRL-D
|
Delete one indent in the current line |
CTRL-T
|
Insert one indent in the current line |
To move from insert mode to command mode press Esc.
where number-of-times is the number of times the operator is repeated, number-of-objects is the number of objects to act on, and an object is either a word (w), sentence, paragraph, section, remainder of the line ($), or "movement" (see movement operators below).
The basic save and exit operators are:
ZZ
|
Quit and save only if changes were made |
:w
|
Save the document |
:wq
|
Save and quit |
The basic editing operators are:
Editing Operators | Movement Operators | ||
c | Begin a change | w | Forward by word |
d | Begin a deletion | b | Backward by word |
y | Begin a yank | ) | Beginning of next sentence |
i | Insert before cursor | ( | Beginning of current sentence |
a | Append after cursor | } | Beginning of next paragraph |
o | Open a line below cursor | { | Beginning of current paragraph |
p | Insert last deleted text after cursor | ] | Beginning of next section |
P | Insert last deleted text before cursor | [ | Beginning of current section |
= | Fix the indenting | H | Top line of screen |
L | Last line of screen | ||
% | Move to the matching bracket | ||
|
|
||
Search Operators | Editing Commands | ||
/text | Search forward for text | :s/old/new | Change the next old to new |
n | Repeat previous search | :s/old/new/g | Change all old on the current line to new |
N | Repeat prev. search in opposite direction | :%s/old/new/g | Change old to new everywhere |
?text | Search backward for text | r | Replace the highlighted character |
:n | Go to line number n | x | Delete the highlighted character |
For example:
2cw
|
Change the next two words |
5yy
|
Yank (i.e., copy) the next five lines |
dw
|
Delete the next word |
d$
|
Delete the remainder of the line |
d%
|
Delete up to the matching bracket |
=%
|
Fix the indenting up to the matching bracket |
Copyright 2019